package com.yyx.app1.Question_function.Control.QuestionListView;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;

import com.android.volley.toolbox.ImageLoader;
import com.yyx.app1.Data.BaseDataManager;
import com.yyx.app1.Data.testDate;
import com.yyx.app1.MyApp;
import com.yyx.app1.R;
import com.yyx.app1.tool.ImageTool;
import com.yyx.app1.ui.ImageShower_Activity;
import com.yyx.app1.ui.ImageShower_Activity_;

import org.androidannotations.annotations.EViewGroup;
import org.androidannotations.annotations.ViewById;

/**
 * Created by yuexing on 2015/10/15.
 */
@EViewGroup(R.layout.listview_head)
public class ListViewHead extends FrameLayout {
    private Context context;
    @ViewById
    ImageView listview_portrait;
    public ListViewHead(Context context) {
        super(context);
        this.context = context;
    }

    public ListViewHead(Context context, AttributeSet attrs) {
        super(context, attrs);
        this.context = context;
    }

    public ListViewHead(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.context = context;
    }

    public void bind(String url)
    {
        ImageLoader imageLoader = BaseDataManager.getMyImageLoader(context);
        if (url!=null)
        {
            imageLoader.get(url, imageLoader.getImageListener(listview_portrait, testDate.loadImageRes,testDate.defaultPortrait),
                    ImageTool.dip2px(context, 80), ImageTool.dip2px(context, 80));
            Bundle tag = new Bundle();
            tag.putString("type","URL");
            tag.putString("value",url);
            ImageShower_Activity.setTagOnClickListener(listview_portrait,context,tag);
        }
    }
}
